package cn.janyd.jmall.dubbo.core.web;

import java.util.Locale;

/**
 * @author janyd
 * @since 2020/8/5 20:31
 */
public class DubboLocaleContextHolder {
    private final static ThreadLocal<String> LOCALE_CONTEXT = new ThreadLocal<>();

    public static void setLocale(String locale) {
        LOCALE_CONTEXT.set(locale);
    }

    public static void setLocale(Locale locale) {
        LOCALE_CONTEXT.set(locale.getLanguage());
    }

    public static String getLocale() {
        return LOCALE_CONTEXT.get();
    }

    public static void clear() {
        LOCALE_CONTEXT.remove();
    }
}
